<?php 
if(!isset($_SESSION)) 
{ 
	session_start(); 
}
$lang = $_SESSION['lang'];
if (empty($lang) || $lang == "EN") {
	include "../../value/value_en.php";
} else if($lang == "VN") {
	include "../../value/value_vn.php";
}
else {
	include "../../value/value_kr.php";
}
include '../../operations/connection.php';
include '../../generallibraries/funcs.php';
$_SESSION['thongbao_employee_salary']="";
$mem=array();
if(isset($_SESSION['emsa'])){
	if(isset($_REQUEST['ngayle']) && isset($_REQUEST['note'])){
		foreach($_SESSION['emsa'] as  $k=>$gt){
			$_SESSION['emsa'][$k][note_holiday]=$_REQUEST['note'];
			$_SESSION['emsa'][$k][note] =$_SESSION['emsa'][$k][note_holiday];
			if($_SESSION['emsa'][$k][note_bonus]!=""){
				if($_SESSION['emsa'][$k][note]==""){
					$_SESSION['emsa'][$k][note]=$_SESSION['emsa'][$k][note_bonus];
				}else{
					$_SESSION['emsa'][$k][note] .=" + ".$_SESSION['emsa'][$k][note_bonus];
				}
			}
			
			$_SESSION['emsa'][$k][number_allow_holiday]=$_REQUEST['ngayle'];
			
			$songaycong_le=$_SESSION['emsa'][$k][really_number_time_work] + $_SESSION['emsa'][$k][number_allow_holiday];
			if($songaycong_le > $_SESSION['emsa'][$k][number_time_work]){
				$songaycong_le=$_SESSION['emsa'][$k][number_time_work];
			}
			$_SESSION['emsa'][$k][paid_salary]=$_SESSION['emsa'][$k][oneday_salary] * ($songaycong_le - $_SESSION['emsa'][$k][number_dateoff] - $_SESSION['emsa'][$k][solannghinuangay_vesom]);
			$_SESSION['emsa'][$k][total_salary]=$_SESSION['emsa'][$k][paid_salary] + $_SESSION['emsa'][$k][allowance_holiday] + $_SESSION['emsa'][$k][allowance_lunch] + $_SESSION['emsa'][$k][allowance_car] + $_SESSION['emsa'][$k][allowance_hard] + $_SESSION['emsa'][$k][overtime_salary];			
			
			$tngaytinhphucap=$songaycong_le - $_SESSION['emsa'][$k][number_dateoff];
			
			if($t[ktngaytinhphucap]<=$_SESSION['chung'][number_max_holiday]){
				$_SESSION['emsa'][$k][allowance_lunch]=$_SESSION['chung'][allowance_lunch] * $tngaytinhphucap / $_SESSION['chung'][number_time_work] ;
				$_SESSION['emsa'][$k][allowance_car]=$_SESSION['chung'][allowance_car] * $tngaytinhphucap / $_SESSION['chung'][number_time_work] ;
			}else{
				$_SESSION['emsa'][$k][allowance_lunch]=$_SESSION['chung'][allowance_lunch] * ($tngaytinhphucap  - $_SESSION['emsa'][$k][solannghinuangay_vesom]) / $_SESSION['chung'][number_time_work] ;
				$_SESSION['emsa'][$k][allowance_car]=$_SESSION['chung'][allowance_car] * ($tngaytinhphucap - $_SESSION['emsa'][$k][solannghinuangay_vesom]) / $_SESSION['chung'][number_time_work] ;
			}
			
			
			$_SESSION['emsa'][$k][total_salary]=$_SESSION['emsa'][$k][paid_salary] + $_SESSION['emsa'][$k][allowance_holiday] + $_SESSION['emsa'][$k][allowance_lunch] + $_SESSION['emsa'][$k][allowance_car] + $_SESSION['emsa'][$k][allowance_hard] +$_SESSION['emsa'][$k][overtime_salary];
			
			$_SESSION['emsa'][$k][received_salary]=$_SESSION['emsa'][$k][total_salary] + $_SESSION['emsa'][$k][salary_bornus] - $_SESSION['emsa'][$k][insurance] - $_SESSION['emsa'][$k][salary_sub];
			if($_SESSION['emsa'][$k][Type_employee]==0){
				$_SESSION['emsa'][$k][received_salary]=$_SESSION['emsa'][$k][received_salary] * 80 /100;
				if($_SESSION['emsa'][$k][note]!=""){
					$_SESSION['emsa'][$k][note] .=" + ".$l_luongthuviec;
				}else{
					$_SESSION['emsa'][$k][note] =$l_luongthuviec;
				}
			}
		}
		$mem=$_SESSION['emsa'];
	}
}
?>
				<table class="rf-dt" width="100%">
					<tr>
						<!-- <th rowspan="2" class="rf-dt-shdr-c"></th> -->
						<th rowspan="2" class="rf-dt-shdr-c"><?php echo $l_no;?></th>
						<th rowspan="2" class="rf-dt-shdr-c"><?php echo $l_employee_name?></th>
						<th rowspan="2" class="rf-dt-shdr-c"><?php echo $l_position?></th>
						<th rowspan="2" class="rf-dt-shdr-c"><?php echo $l_number_time_work?></th>
						<th rowspan="2" class="rf-dt-shdr-c"><?php echo $l_num_allow_holiday?></th>
						<th rowspan="2" class="rf-dt-shdr-c"><?php echo $l_basicsalary?></th>
						<th rowspan="2" class="rf-dt-shdr-c"><?php echo $l_allowancebasicsalary?></th>
						<th rowspan="2" class="rf-dt-shdr-c"><?php echo $l_dayoff?></th>
						<th rowspan="2" class="rf-dt-shdr-c"><?php echo $l_absentmonth?></th>
						<th rowspan="2" class="rf-dt-shdr-c"><?php echo $l_comebackearly?></th>
						<th rowspan="2" class="rf-dt-shdr-c"><?php echo  $l_comelately?></th>
						<th rowspan="2" class="rf-dt-shdr-c"><?php echo $l_allowanceSenior?></th>
						<th rowspan="2" class="rf-dt-shdr-c"><?php echo $l_allowanceC?></th>
						<th rowspan="2" class="rf-dt-shdr-c"><?php echo $l_salaryperday?></th>
						<th rowspan="2" class="rf-dt-shdr-c"><?php echo $l_salaryreceived?></th>
						<th rowspan="2" class="rf-dt-shdr-c"><?php echo $l_allowance_holiday?></th>
						<th colspan="2" class="rf-dt-shdr-c"><?php echo $l_allowance?></th>
						<th rowspan="2" class="rf-dt-shdr-c"><?php echo $l_allowance_hard?></th>
						<th colspan="2" class="rf-dt-shdr-c"><?php echo $l_allowance_overtime?></th>
						<th rowspan="2" class="rf-dt-shdr-c"><?php echo $l_total?></th>
						<th rowspan="2" class="rf-dt-shdr-c"><?php echo $l_socialInsurance?></th>
						<th rowspan="2" class="rf-dt-shdr-c"><?php echo $l_salary_bonus?></th>
						<!-- <th rowspan="2" class="rf-dt-shdr-c"><?php echo $l_salary_sub?></th> -->
						<th rowspan="2" class="rf-dt-shdr-c"><?php echo $l_realreceived?></th>
						<th rowspan="2" class="rf-dt-shdr-c"><?php echo $l_note;?></th>
					</tr>
					<tr>
						<th class="rf-dt-shdr-c"><?php echo $l_lunch?></th>
						<th class="rf-dt-shdr-c"><?php echo $l_parking?></th>
						<th class="rf-dt-shdr-c"><?php echo $l_numbersession?></th>
						<th class="rf-dt-shdr-c"><?php echo $l_total_amount?></th>
					</tr>
					<tr style="background: #93cddd; color: white;text-align:center;">
						<!--  <td class="rf-dt-c"></td> -->
						<td class="rf-dt-c"></td>
						<td class="rf-dt-c">(2)</td>
						<td class="rf-dt-c">(3)</td>
						<td class="rf-dt-c">(4)</td>
						<td class="rf-dt-c"></td>
						<td class="rf-dt-c">(5)</td>
						<td class="rf-dt-c">(6)</td>
						<td class="rf-dt-c">(7)</td>
						<td class="rf-dt-c">(8)</td>
						<td class="rf-dt-c">(9)</td>
						<td class="rf-dt-c">(10)</td>
						<td class="rf-dt-c">(11)</td>
						<td class="rf-dt-c">(12)</td>
						<td class="rf-dt-c">(13)=[(5)+(6) +(11)+(12)]/4</td>
						<td class="rf-dt-c">(14)=(13) x [(4)-7)]</td>
						<td class="rf-dt-c">(15)</td>
						<td class="rf-dt-c">(16)</td>
						<td class="rf-dt-c">(17)</td>
						<td class="rf-dt-c">(18)</td>
						<td class="rf-dt-c">(19)</td>
						<td class="rf-dt-c">(20)= 240000x(19)</td>
						<td class="rf-dt-c">(21)=(14)+(15) +(16)+(17) +(28)+(20)</td>
						<td class="rf-dt-c">(22)</td>
						<td class="rf-dt-c">(23)</td>
						<!-- <td class="rf-dt-c">(24)</td> -->
						<td class="rf-dt-c">(24)=(21)+(23)-(22)</td>
						<td class="rf-dt-c"></td>
					</tr>
					
					<?php 
						$sum_received=0;
						if(count($mem)>0){
							$vitri=0;
							foreach($mem as $khoa=>$giatri){
								?>
								<tr class="hang">
									<!-- <td class="rf-dt-c"><input type="checkbox" name="list" id="<?php echo "check".$khoa;?>" value="<?=$khoa?>"/></td> -->
									<td class="rf-dt-c"><?php echo ($vitri+1);?></td>
									<td class="rf-dt-c"><?php echo $giatri[name];?></td>
									<td class="rf-dt-c"><?php echo $giatri[position];?></td>
									<td class="rf-dt-c"><?php echo $giatri[really_number_time_work]."/".$giatri[number_time_work];?></td>
									<td class="rf-dt-c"><?php echo $giatri[number_allow_holiday];?></td>
									<td class="rf-dt-c"><?php echo number_format($giatri[basic_salary]);?></td>
									<td class="rf-dt-c"><?php echo number_format($giatri[allowance_basic_salary]);?></td>
									<td class="rf-dt-c"><?php echo $giatri[number_dateoff];?></td>
									<td class="rf-dt-c"><?php echo $giatri[number_holiday];?></td>
									<td class="rf-dt-c"><?php echo $giatri[number_is_comeback_early];?></td>
									<td class="rf-dt-c"><?php echo $giatri[number_is_late];?></td>
									<td class="rf-dt-c"><?php echo number_format($giatri[allowance_senior]);?></td>
									<td class="rf-dt-c"><?php echo number_format($giatri[allowance_c]);?></td>
									<td class="rf-dt-c"><?php echo number_format($giatri[oneday_salary]);?></td>
									<td class="rf-dt-c"><?php echo number_format($giatri[paid_salary]);?></td>
									<td class="rf-dt-c"><?php echo number_format($giatri[allowance_holiday]);?></td>
									<td class="rf-dt-c"><?php echo number_format($giatri[allowance_lunch]);?></td>
									<td class="rf-dt-c"><?php echo number_format($giatri[allowance_car]);?></td>
									<td class="rf-dt-c"><?php echo number_format($giatri[allowance_hard]);?></td>
									<td class="rf-dt-c"><?php echo $giatri[number_overtime];?></td>
									<td class="rf-dt-c"><?php echo number_format($giatri[overtime_salary]);?></td>
									<td class="rf-dt-c"><?php echo number_format($giatri[total_salary]);?></td>
									<td class="rf-dt-c"><?php echo number_format($giatri[insurance]);?></td>
									<td class="rf-dt-c"><?php echo number_format($giatri[salary_bornus]);?></td>
									<!-- <td class="rf-dt-c"><?php echo number_format($giatri[salary_sub]);?></td> -->
									<td class="rf-dt-c"><?php echo number_format($giatri[received_salary]);?></td>
									<td class="rf-dt-c"><?php echo $giatri[note];?></td>
								</tr>
								<?php 
								$vitri++;
								$sum_received +=$giatri[received_salary];
							}
						}
					?>
					<tr>
						<td colspan="24" class="rf-dt-c"></td>
						<td class="rf-dt-c" style="background: #93cddd;font-weight: bold;"><?php echo number_format($sum_received);?></td>
						<td class="rf-dt-c"></td>
					</tr>
				</table> 
				<?php mysql_close($connection);?>